/**
 *   获取url参数
 *   例：getParamsCode('id');
 */
export function getParamsCode(name) {
    const search = decodeURIComponent(location.href).split('?');
    if (search.length < 2) return undefined; //没有参数，直接undefined
    let queryParams = search[1];
    //处理桌面版描述文件奇怪url /uuid/ => &uuid=
    if (search[1].indexOf('/uuid/') > -1) {
        queryParams = queryParams.replace(/\//, '&').replace(/\//, '=');
    }
    queryParams = queryParams.split('&');
    let i = 0,
        len = queryParams.length,
        params = {},
        pos;
    for (; i < len; i++) {
        pos = queryParams[i].indexOf('=');
        if (pos > 0) {
            params[queryParams[i].substring(0, pos)] = queryParams[i].substring(pos + 1);
        }
    }

    return params[name] ? params[name] : undefined;
}
